package com.codegenerate.demo.dto;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codegenerate.demo.config.R;
import com.codegenerate.demo.entity.SysClass;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

public class SysClassDto implements Serializable {
    private long id;

    int pageNum;
    int pageSize;
    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public R validateUpdate(){
        if(this.getId()<0){
            return R.failed("id 不能为空");
        }
        return R.ok(null);
    }










    /**
     * 分类名称
     */
    private String name;




    /**
     * 所属上级类别[关系=SysClass]
     */
    private int parentId;




    /**
     * 所有分类路径
     */
    private String parentIdPath;




    /**
     * 拓展类型
     */
    private String expendType;




    /**
     * 类别深度
     */
    private int deep;




    /**
     * 分类类型名称
     */
    private String typeInfo;




    /**
     * 分类图片[查询]
     */
    private String img;




    /**
     * 排序号
     */
    private int orderNum;




    /**
     * 备注
     */
    private String remarks;




    /**
     * 信息级别 0系统级 10租户级
     */
    private int infoLevel;




    /**
     * 租户类型 1应用管理者2应用消息者
     */
    private int tenantType;




    /**
     * 租户ID
     */
    private int tenantId;




    /**
     * 有效状态[数据字典=del_state] 1有效  5删除
     */
    private int delState;




    /**
     * 添加人
     */
    private String addUser;




    /**
     * 添加人ID
     */
    private int addUserId;




    /**
     * 添加时间
     */
    private LocalDateTime addTime;




    /**
     * 最近更新人
     */
    private String editUser;




    /**
     * 最近更新人ID
     */
    private int editUserId;




    /**
     * 最近更新时间
     */
    private LocalDateTime lastEditTime;




    /**
     * 服务器编号ID
     */
    private int serverNumber;









    public  long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public int getParentId() {
        return parentId;
    }
    public void setParentId(int parentId) {
        this.parentId = parentId;
    }

    public String getParentIdPath() {
        return parentIdPath;
    }
    public void setParentIdPath(String parentIdPath) {
        this.parentIdPath = parentIdPath;
    }

    public String getExpendType() {
        return expendType;
    }
    public void setExpendType(String expendType) {
        this.expendType = expendType;
    }

    public int getDeep() {
        return deep;
    }
    public void setDeep(int deep) {
        this.deep = deep;
    }

    public String getTypeInfo() {
        return typeInfo;
    }
    public void setTypeInfo(String typeInfo) {
        this.typeInfo = typeInfo;
    }

    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }

    public int getOrderNum() {
        return orderNum;
    }
    public void setOrderNum(int orderNum) {
        this.orderNum = orderNum;
    }

    public String getRemarks() {
        return remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public int getInfoLevel() {
        return infoLevel;
    }
    public void setInfoLevel(int infoLevel) {
        this.infoLevel = infoLevel;
    }

    public int getTenantType() {
        return tenantType;
    }
    public void setTenantType(int tenantType) {
        this.tenantType = tenantType;
    }

    public int getTenantId() {
        return tenantId;
    }
    public void setTenantId(int tenantId) {
        this.tenantId = tenantId;
    }

    public int getDelState() {
        return delState;
    }
    public void setDelState(int delState) {
        this.delState = delState;
    }

    public String getAddUser() {
        return addUser;
    }
    public void setAddUser(String addUser) {
        this.addUser = addUser;
    }

    public int getAddUserId() {
        return addUserId;
    }
    public void setAddUserId(int addUserId) {
        this.addUserId = addUserId;
    }

    public LocalDateTime getAddTime() {
        return addTime;
    }
    public void setAddTime(LocalDateTime addTime) {
        this.addTime = addTime;
    }

    public String getEditUser() {
        return editUser;
    }
    public void setEditUser(String editUser) {
        this.editUser = editUser;
    }

    public int getEditUserId() {
        return editUserId;
    }
    public void setEditUserId(int editUserId) {
        this.editUserId = editUserId;
    }

    public LocalDateTime getLastEditTime() {
        return lastEditTime;
    }
    public void setLastEditTime(LocalDateTime lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public int getServerNumber() {
        return serverNumber;
    }
    public void setServerNumber(int serverNumber) {
        this.serverNumber = serverNumber;
    }




    /**
     * build
     */
    public static SysClassDto build(){
        SysClassDto temp = new SysClassDto();



        temp.setId(0);

        temp.setName("");

        temp.setParentId(0);

        temp.setParentIdPath("");

        temp.setExpendType("");

        temp.setDeep(0);

        temp.setTypeInfo("");

        temp.setImg("");

        temp.setOrderNum(0);

        temp.setRemarks("");

        temp.setInfoLevel(0);

        temp.setTenantType(0);

        temp.setTenantId(0);

        temp.setDelState(1);

        temp.setAddUser("");

        temp.setAddUserId(0);

        temp.setAddTime(LocalDateTime.now());

        temp.setEditUser("");

        temp.setEditUserId(0);

        temp.setLastEditTime(LocalDateTime.now());

        temp.setServerNumber(0);


        return temp;
    }

    /**
     * setDefaultValue
     */
    public void  setDefaultValue(SysClassDto temp){

        if(this.id<=0){
            temp.setId(0);
        }

        if(StringUtils.isEmpty(this.name)){
            temp.setName("");
        }

        if(this.parentId<=0){
            temp.setParentId(0);
        }

        if(StringUtils.isEmpty(this.parentIdPath)){
            temp.setParentIdPath("");
        }

        if(StringUtils.isEmpty(this.expendType)){
            temp.setExpendType("");
        }

        if(this.deep<=0){
            temp.setDeep(0);
        }

        if(StringUtils.isEmpty(this.typeInfo)){
            temp.setTypeInfo("");
        }

        if(StringUtils.isEmpty(this.img)){
            temp.setImg("");
        }

        if(this.orderNum<=0){
            temp.setOrderNum(0);
        }

        if(StringUtils.isEmpty(this.remarks)){
            temp.setRemarks("");
        }

        if(this.infoLevel<=0){
            temp.setInfoLevel(0);
        }

        if(this.tenantType<=0){
            temp.setTenantType(0);
        }

        if(this.tenantId<=0){
            temp.setTenantId(0);
        }

        if(this.delState<=0){
            temp.setDelState(1);
        }

        if(StringUtils.isEmpty(this.addUser)){
            temp.setAddUser("");
        }

        if(this.addUserId<=0){
            temp.setAddUserId(0);
        }

        if(null==this.addTime){
            temp.setAddTime(LocalDateTime.now());
        }

        if(StringUtils.isEmpty(this.editUser)){
            temp.setEditUser("");
        }

        if(this.editUserId<=0){
            temp.setEditUserId(0);
        }

        if(null==this.lastEditTime){
            temp.setLastEditTime(LocalDateTime.now());
        }

        if(this.serverNumber<=0){
            temp.setServerNumber(0);
        }

    }



    /**
     * dto2entity
     */
    public SysClass dto2entity(){
        var entity=SysClass.build();

        if(this.id>0){
            entity.setId(this.getId());
        }

        if(!StringUtils.isEmpty(this.name)){
            entity.setName(this.getName());
        }

        if(this.parentId>0){
            entity.setParentId(this.getParentId());
        }

        if(!StringUtils.isEmpty(this.parentIdPath)){
            entity.setParentIdPath(this.getParentIdPath());
        }

        if(!StringUtils.isEmpty(this.expendType)){
            entity.setExpendType(this.getExpendType());
        }

        if(this.deep>0){
            entity.setDeep(this.getDeep());
        }

        if(!StringUtils.isEmpty(this.typeInfo)){
            entity.setTypeInfo(this.getTypeInfo());
        }

        if(!StringUtils.isEmpty(this.img)){
            entity.setImg(this.getImg());
        }

        if(this.orderNum>0){
            entity.setOrderNum(this.getOrderNum());
        }

        if(!StringUtils.isEmpty(this.remarks)){
            entity.setRemarks(this.getRemarks());
        }

        if(this.infoLevel>0){
            entity.setInfoLevel(this.getInfoLevel());
        }

        if(this.tenantType>0){
            entity.setTenantType(this.getTenantType());
        }

        if(this.tenantId>0){
            entity.setTenantId(this.getTenantId());
        }

        if(this.delState>0){
            entity.setDelState(this.getDelState());
        }

        if(!StringUtils.isEmpty(this.addUser)){
            entity.setAddUser(this.getAddUser());
        }

        if(this.addUserId>0){
            entity.setAddUserId(this.getAddUserId());
        }

        if(null!=this.addTime){
            entity.setAddTime(this.getAddTime());
        }

        if(!StringUtils.isEmpty(this.editUser)){
            entity.setEditUser(this.getEditUser());
        }

        if(this.editUserId>0){
            entity.setEditUserId(this.getEditUserId());
        }

        if(null!=this.lastEditTime){
            entity.setLastEditTime(this.getLastEditTime());
        }

        if(this.serverNumber>0){
            entity.setServerNumber(this.getServerNumber());
        }

        return entity;
    }



    public Page<SysClass> buildPage(){
        Page<SysClass> tempage = new Page<SysClass>();
        tempage.setCurrent(this.getPageNum()<=0?0:this.getPageNum());
        tempage.setSize(this.getPageSize()<=0?10:this.getPageSize());
        return tempage;
    }


}